#include "app_run.h"
#include "app_device.h"
#include "app_bt.h"
#include "signal.h"
#include <unistd.h>



int is_running = 1;

void exit_handler(int signum)
{
    is_running = 0;
}

int app_run(void)
{
    //注册结束的信号处理
    signal(SIGINT, exit_handler);  //crtl + c
    signal(SIGTERM, exit_handler); //kill 进程

    //初始化
    Device *device = app_device_init(DEVICE_FILE); //设备初始化
    app_bt_init(device);    //蓝牙初始化

    //启动设备
    app_device_start();
    while(is_running)
    {
        sleep(1);
    }
    //释放资源
    app_device_destroy();

    return 0;
}